#pragma GCC optimize(2, "Ofast", "inline")
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <algorithm>
#define endl '\n'
#define int long long
#define pii pair<int, int>
using namespace std;

// 已知
string s;

// 未知

int b = 0;
int cnt = 0;
signed main()
{
    cin.tie(0)->sync_with_stdio(0);
    cin >> s;
    cnt += s.size();
    for (int i = 1;i < s.size();i++)
    {
        cnt += (s[i - 1] - s[i] + 10) % 10;
    }
    cnt += s[s.size() - 1] - '0';
    cout << cnt;
    return 0;
}